import React, { createContext, useMemo } from 'react';
import { DataSet } from 'choerodon-ui/pro';
import tableInlineDS from './tableInlineDataSet';

const Store = createContext<Partial<{ children: React.ReactElement, tableInlineDataSet: DataSet }>>({});

export default Store;


export const StoreProvider = (props: { children: React.ReactElement; }) => {
    const { children } = props;
    const tableInlineDataSet = useMemo(() => new DataSet(tableInlineDS()), []);
    const value = {
        ...props,
        tableInlineDataSet,
    };

    return (
      <Store.Provider value={value}>
        {children}
      </Store.Provider>
    );
};